<template>
	<div class="app-container">
		<div class="row3">
			<span class="left-label">时间筛选</span>
			<el-date-picker
				v-model="queryData.teststartTime"
				style="width: 356px; margin-right: 10px"
				value-format="YYYY-MM-DD"
				type="daterange"
				range-separator="-"
				start-placeholder="开始时间"
				end-placeholder="结束时间"></el-date-picker>
			<el-button type="primary" @click="search">搜索</el-button>
			<el-button @click="reset">重置</el-button>
		</div>
		<BaseTable :columns="columns" :dataList="dataList"> </BaseTable>
		<div>
			<span>总分：{{ total }}</span>
			<span style="float: right">平均分：{{ avl }}</span>
		</div>
	</div>
</template>
<script setup>
import { reactive } from 'vue'
import BaseTable from '@/components/BaseTable'
import { qualitys } from '@/api/board/index'
import useUserStore from '@/store/modules/user'
import { useRoute } from 'vue-router'
const route = useRoute()

const userStore = useUserStore()

const { proxy } = getCurrentInstance()
const { problem_status } = proxy.useDict('problem_status')
const router = useRouter()

const columns = ref([
	{ key: 1, label: `客户名称`, prop: 'channelName', type: 'text', visible: true },
	{ key: 2, width: '150', label: `项目名称`, prop: 'projectName', type: 'text', visible: true },
	{ key: 3, width: '150', label: `评分分数`, prop: 'evaluateScore', type: 'text', visible: true },
	{ key: 4, width: '150', label: `评分时间`, prop: 'createTime', type: 'dateTime', visible: true }
])
const total = ref(0)
const avl = ref(0)
const dataList = ref([])

const queryData = reactive({
	teststartTime: undefined,
	createUserCode: route.query.createUserCode
})
const search = () => {
	const querys = toRaw(queryData)
	const obj = { ...querys }
	if (obj.teststartTime) {
		obj.startTime = obj.teststartTime[0]
		obj.endTime = obj.teststartTime[1]
		obj.teststartTime = undefined
	}
	qualitys(obj).then((res) => {
		if (res.projectStaffEvaluateCountVos) {
			dataList.value = res.projectStaffEvaluateCountVos
		} else {
			dataList.value = []
		}
		if (res.summaryScore) {
			total.value = res.summaryScore
		} else {
			total.value = 0
		}
		if (res.averageScore) {
			avl.value = res.averageScore
		} else {
			avl.value = 0
		}
	})
}
const reset = () => {
	queryData.teststartTime = undefined
	search()
}
search()
</script>
<style lang="scss" scoped>
.left-label {
	color: #33b6fe;
	height: 24px;
	line-height: 24px;
	position: relative;
	top: 1px;
	margin-right: 10px;
	display: inline-block;
	min-width: 80px;
}
:deep(.el-table__header) {
	background-color: #2f3f56;
}

.row3 {
	border-bottom: 1px rgba(240, 240, 240, 1) solid;
	padding: 5px 0 10px 0;
}
</style>
